package org.aurora.framework.boot.domain;

import java.io.Serializable;

/**
 * AbstractDomainService
 * <pre>
 * description:
 * create date: 2025-03-22 17:38:14
 * </pre>
 *
 * @author cao.yong
 */
public abstract class AbstractDomainService<E extends Entity<ID>, R extends DomainRepository<E, ID>, ID extends Serializable> implements DomainService<E, ID> {

    protected final R repository;

    public AbstractDomainService(R repository) {
        this.repository = repository;
    }

    protected R getRepository() {
        return repository;
    }

    @Override
    public void create(E entity) {
        this.repository.save(entity);
    }

    @Override
    public void remove(ID id) {
        this.repository.delete(id);
    }

    @Override
    public void remove(E entity) {
        this.repository.delete(entity);
    }

    @Override
    public void modify(E entity) {
        this.repository.update(entity);
    }
}
